<template>
  <div class="box">
    <div class="header">
      <div class="top">
        <img src="../../../assets//image/shop/jiangpai.png" alt="" />
        <span>诚信商家</span>
      </div>
      <div class="bottom">官方认证商家</div>
    </div>

    <div class="shopbox">
      <div class="shopname">{{ storeData.storeName }}</div>
      <div class="shopguanzhu" v-if="storeData.collection">
        <img src="../../../assets//image/shop/guanzhu.png" alt="" />
        <span>已关注</span>
      </div>
      <div class="shopguanzhu" v-else @click="saveStoreCollection">
        <img src="../../../assets//image/shop/guanzhu.png" alt="" />
        <span>关注店铺</span>
      </div>
    </div>

    <div class="shopmsg">
      <div class="left">商品数量：</div>
      <div class="right">{{ storeData.productSum }}款</div>
    </div>

    <div class="shopmsg">
      <div class="left">最近上新：</div>
      <div class="right">{{ storeData.lastNewDate }}</div>
    </div>

    <div class="shopmsg">
      <div class="left">商家电话：</div>
      <div class="specialright">
        <span v-if="phoneShow && storeData.storePhone">{{
          storeData.storePhone | phoneFilter
        }}</span>
        <span v-else>{{ storeData.storePhone }}</span>
        <span style="cursor: pointer" @click="phoneShow = false">查看</span>
      </div>
    </div>

    <div class="shopmsg">
      <div class="left">商家微信：</div>
      <div class="right" style="display: flex; cursor: pointer">
        <!-- {{storeData.storeWw}} -->
        <el-tooltip
          class="item"
          effect="light"
          :content="storeData.storeVx"
          placement="top"
        >
          <img src="../../../assets/image/bottom/wx.png" alt="" />
        </el-tooltip>
      </div>
    </div>

    <div class="shopmsg">
      <div class="specialleft">
        商家地址：{{ storeData.storeAddressDetail }}
      </div>
    </div>

    <div class="shopmsg">
      <div class="left">店铺资质：</div>
      <div class="right" style="cursor: pointer">
        <img
          @click="toWinIo(storeData.businessLicense)"
          src="../../../assets/image/shop/zhizhao.png"
          alt=""
        />
      </div>
    </div>
  </div>
</template>

<script>
import { saveStoreCollection } from "@/api/MyCollection";
import { getToken, removeToken } from "@/utils/auth";
export default {
  props: ["storeData"],

  data() {
    return {
      phoneShow: true,
    };
  },
  filters: {
    // 手机号过滤器
    phoneFilter(val) {
      const reg = /^(.{3}).*(.{4})$/;
      return val.replace(reg, "$1****$2");
    },
  },
  created() {},
  methods: {
    toWinIo(url) {
      if (!url) {
        this.$message({
          message: "该店铺未上传营业执照",
          type: "warning",
        });
      } else {
        window.open(url);
      }
    },
    // 收藏店铺
    saveStoreCollection() {
      const token = getToken();
      if (token) {
        saveStoreCollection({
          idList: `${this.storeData.id}`,
        }).then((data) => {
          if (data.code == 200) {
            this.$message({
              message: "关注成功",
              type: "success",
            });
            this.$parent.pmsStore(this.storeData.id);
          }
        });
      } else {
        this.$message({
          message: "请先登陆！",
          type: "warning",
        });
      }
    },
  },
};
</script>

<style scoped lang="scss">
.box {
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  .header {
    width: 100%;
    height: 0.64rem;
    background: linear-gradient(97deg, #fd4422 17%, #ff6721 98%);
    border-radius: 0.04rem 0.04rem 0px 0px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    .top {
      font-size: 0.2rem;
      display: flex;
      align-items: center;
      margin-bottom: 0.05rem;
      img {
        width: 0.2rem;
        height: auto;
        margin-right: 0.05rem;
      }
    }
    .bottom {
      font-size: 0.14rem;
    }
  }
  .shopbox {
    width: 100%;
    height: 0.76rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #000000;
    border-bottom: 0.005rem solid #e8e8e8;
    .shopname {
      font-size: 0.2rem;
      margin-bottom: 0.1rem;
      font-weight: bold;
    }
    .shopguanzhu {
      cursor: pointer;
      width: 0.8rem;
      height: 0.19rem;
      border-radius: 0.1rem;
      font-size: 0.12rem;
      color: #ec6c15;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 0.01rem solid #ec6c15;
      img {
        width: 0.14rem;
        height: 0.14rem;
        margin-right: 0.05rem;
      }
    }
  }
  .shopmsg:last-child {
    border-bottom: none;
  }
  .shopmsg {
    width: 100%;
    min-height: 0.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.16rem;
    color: #666666;
    border-bottom: 0.005rem solid #e8e8e8;
    .left {
      width: 0.8rem;
      text-align: center;
    }
    .specialleft {
      padding: 0.1rem 0.1rem;
      width: calc(100% - 0.2rem);
      text-align: left;
      line-height: 0.2rem;
      padding-left: 0;
    }
    .right {
      flex: 1;
      text-align: left;
    }
    .specialright {
      flex: 1;
      text-align: left;
      color: #ec6c15;
      span {
        margin-right: 0.1rem;
      }
    }
  }
}
</style>
<style scoped lang="scss">
// @media screen and (max-width: 1300px) {
//   .box {
//     width: 100%;
//     height: 100%;
//     background: #ffffff;
//     display: flex;
//     flex-direction: column;
//     justify-content: flex-start;
//     align-items: center;
//     .header {
//       width: 100%;
//       height: 0.64rem;
//       background: linear-gradient(97deg, #fd4422 17%, #ff6721 98%);
//       border-radius: 0.04rem 0.04rem 0px 0px;
//       display: flex;
//       flex-direction: column;
//       justify-content: center;
//       align-items: center;
//       color: #ffffff;
//       .top {
//         font-size: 0.2rem;
//         display: flex;
//         align-items: center;
//         margin-bottom: 0.05rem;
//         img {
//           width: 0.2rem;
//           height: auto;
//           margin-right: 0.05rem;
//         }
//       }
//       .bottom {
//         font-size: 0.14rem;
//       }
//     }
//     .shopbox {
//       width: 100%;
//       height: 0.76rem;
//       display: flex;
//       flex-direction: column;
//       justify-content: center;
//       align-items: center;
//       color: #000000;
//       border-bottom: 0.005rem solid #e8e8e8;
//       .shopname {
//         font-size: 0.2rem;
//         margin-bottom: 0.1rem;
//         font-weight: bold;
//       }
//       .shopguanzhu {
//         cursor: pointer;
//         width: 1.2rem;
//         height: 0.19rem;
//         border-radius: 0.1rem;
//         font-size: 0.12rem;
//         color: #ec6c15;
//         display: flex;
//         justify-content: center;
//         align-items: center;
//         border: 0.01rem solid #ec6c15;
//         img {
//           width: 0.14rem;
//           height: 0.14rem;
//           margin-right: 0.05rem;
//         }
//       }
//     }
//     .shopmsg:last-child {
//       border-bottom: none;
//     }
//     .shopmsg {
//       width: 100%;
//       min-height: 0.4rem;
//       display: flex;
//       justify-content: space-between;
//       align-items: center;
//       font-size: 0.12rem;
//       color: #666666;
//       border-bottom: 0.005rem solid #e8e8e8;
//       .left {
//         width: 1rem;
//         text-align: center;
//       }
//       .specialleft {
//         padding: 0.1rem 0.1rem;
//         width: calc(100% - 0.2rem);
//         text-align: left;
//         line-height: 0.2rem;
//       }
//       .right {
//         flex: 1;
//         text-align: left;
//       }
//       .specialright {
//         flex: 1;
//         text-align: left;
//         color: #ec6c15;
//         span {
//           margin-right: 0.1rem;
//         }
//       }
//     }
//   }
// }
</style>
